<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
include_once("JO_01_configuration.php");
include_once("JO_02_function.php");
$JO_MySQL = new mysqli( $JO_DB_host, $JO_DB_user, $JO_DB_password, $JO_DB_database );
$JO_MySQL -> query( "SET NAMES 'UTF8'" );
if(isset($_REQUEST["JO_channel"]) && $_REQUEST["JO_channel"]!=""){$JO_channel=$_REQUEST["JO_channel"];}
if(!isset($_REQUEST["episode"])){
            $query="SELECT
                `show`.`key`,
                `show`.`subject`,
                `show`.description,
                `show`.viewer,
                `show`.episode,
                `show`.image,
                `show`.note,
                `show`.log,
                `show`.`insert`,
                `show`.`update`,
                `show`.`delete`,
                (select GROUP_CONCAT(show_detail.part  separator ';') FROM show_detail where show_detail.`delete` is null and show_detail.`show`=`show`.`key` ".(isset($JO_channel)?(" and `show`.channel=".$JO_channel):"").") as parts
                FROM
                `show`
                WHERE `show`.`delete` is null ".(isset($JO_channel)?(" and `show`.channel=".$JO_channel):"")."
                GROUP BY
                `show`.`key`
                ORDER BY
                `show`.episode asc
                limit ".(($_REQUEST["startepisode"]==-1)?"0,1":($_REQUEST["startepisode"].",2"))."

                    ";
            $recordSet = JO_query( $query );
            if($recordSet->num_rows) while($record = $recordSet -> fetch_array( )){

?>

 <div style="padding: 0px 0px 4px 0px;width: 334px;float: left;">
    <span style="display: inline-block;
        _display: inline;
        _zoom: 1;
        padding: 4px;
        background: white;
        overflow: hidden;
        border: 1px solid lightGrey;
        border-radius: 3px;
        -moz-border-radius: 3px;
        -webkit-border-radius: 3px;
        _line-height: 0;">
        <a href="<?=(($record["parts"]>0)?("?JO_unit=50_TV&episode=".$record["episode"].(isset($JO_channel)?("&JO_channel=".$JO_channel):"")):"#i")?>">
            <img src="<?=$record["image"]?>" width="120px" height="90px;"/>
        </a>
<!--                                    <span style="padding: 0 4px;
                    font-weight: normal;
                    font-size: 11px;
                    -moz-border-radius: 3px;
                    -webkit-border-radius: 3px;
                    border-radius: 3px;
                    background-color: black;
                    color: white!important;
                    height: 14px;
                    line-height: 14px;
                    opacity: 0.75;
                    filter: alpha(opacity=75);
                    display: -moz-inline-stack;
                    display: inline-block;
                    vertical-align: top;
                    zoom: 1;margin-top: 0;
                    margin-right: 0;
                    position: absolute;
                    left: 5px;
                    bottom: 9px;">
            3:25
        </span>-->
        <div style="
                                                font-weight: normal;
                                                font-size: 11px;
                                                width: 204px;
                                                height: 14px;
                                                line-height: 14px;
                                                opacity: 0.75;
                                                filter: alpha(opacity=75);
                                                display: inline-block;
                                                vertical-align: top;
                                                margin-right: 0;
                                                position: absolute;
                                                left: 136px;
												padding: 0px;
                                                bottom: 9px;">
            <?
             if(isset ($record["parts"])){
                 $parts=array();
                 $parts=explode(";", $record["parts"]);
                 $linkpart="";
                 $numpart=0;
                 foreach ($parts as $value){
                    if($value!=""){
                        $linkpart.="<a href='?JO_unit=50_TV&episode=".$record["episode"]."&part=".$value.(isset($JO_channel)?("&JO_channel=".$JO_channel):"")."'>Phần ".$value."</a>&nbsp;&nbsp;";
                        $numpart++;
                    }
                 }
                 if($numpart>1) echo $linkpart;
                 else echo "<a href='?JO_unit=50_TV&episode=".$record["episode"].(isset($JO_channel)?("&JO_channel=".$JO_channel):"")."'>Xem</a>";
             }else echo "Đang Cập Nhật";
            ?>
        </div>
    </span>
    
    <div style="width: 204px; padding: 0px;position: absolute;top:0px;left: 136px;">
<!--                                <div style="width: 546px;float: right;">-->
        <span style="font-weight: bold;padding: 0px;margin: 0px;border-bottom: 0px;background-color: inherit;">
            <a href="<?=(($record["parts"]>0)?("?JO_unit=50_TV&episode=".$record["episode"].(isset($JO_channel)?("&JO_channel=".$JO_channel):"")):"#i")?>">
                <?=$record["subject"]?>
            </a>
        </span><br/>
        <span>
            <?=$record["description"]?>
        </span>
    </div>

</div>
<?
            }
}
?>